package com.hzj.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if (request.getRequestURI().contains("register")){
            return true;
        }
        if (request.getRequestURI().contains("toRegister")){
            return true;
        }
        if (request.getRequestURI().contains("login")){
            return true;
        }
        if (request.getSession().getAttribute("userInfo")!=null){
            return true;
        }
        request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request,response);
            return false;
    }
}
